package io.renren.modules.store.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.store.entity.vo.FoodDiscountVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.store.dao.TStoreDiscountDao;
import io.renren.modules.store.entity.TStoreDiscountEntity;
import io.renren.modules.store.service.TStoreDiscountService;


@Service("tStoreDiscountService")
public class TStoreDiscountServiceImpl extends ServiceImpl<TStoreDiscountDao, TStoreDiscountEntity> implements TStoreDiscountService {

    @Autowired
    private TStoreDiscountDao tStoreDiscountDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TStoreDiscountEntity> page = this.page(
                new Query<TStoreDiscountEntity>().getPage(params),
                new QueryWrapper<TStoreDiscountEntity>()
                        .eq(!params.get("sellerId").equals(""),"seller_id",params.get("sellerId"))
                        .eq(params.get("status") != null,"status",params.get("status"))
        );

        return new PageUtils(page);
    }

    @Override
    public Page<FoodDiscountVo> listFoodDetail(Map<String, Object> params) {
        Page<FoodDiscountVo> page = new Page<FoodDiscountVo>
                (Long.parseLong((String) params.get("current")),Long.parseLong((String) params.get("size")));
        return tStoreDiscountDao.listFoodDetail(page, params);
    }

}